import Vue from 'vue';
import Vuex from 'vuex'
Vue.use(Vuex)
const state = {
	isCollapse: true,
  Tags: [
    // {
    //   name: "用户管理",
    //   active: true,
    //   path: "/system"
    // }
  ]
}
const mutations = {
	toggle(state) {
		state.isCollapse = !state.isCollapse
	},
  //删除标签页
  delTab(state, index) {
    this.state.Tags.splice(index, 1);
  },
  //添加标签
  addTab(state,tab) {
	  var flag = 0;
	  state.Tags.forEach((item, index) => {
	    if(item.path == tab.path) {
        flag = 1;
      }
    });
    if(flag == 0) {
      state.Tags.push(tab);
    }
  },
  //添加高亮标签
  checkActive(state, path) {
	  state.Tags.forEach(item => {
	    item.active = false
	    if(item.path == path) {
	      item.active = true
      }
    });
	  console.log(state.Tags)
  }
}
export default new Vuex.Store({
	state,
	mutations
})
